package com.CloudDream.Gui.gui;

import com.CloudDream.Gui.MYInventoryHolder;
import com.CloudDream.Inventory.InventoryItem;
import com.CloudDream.Inventory.InventorySlot;
import com.CloudDream.Item.Creator;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import java.util.Arrays;
import java.util.List;

public class MainGui {

    private static final int[] slot = new int[]{InventorySlot.MATERIAL_BUTTON, InventorySlot.RECIPE_BUTTON, InventorySlot.MOONCAKE_BUTTON};
    private static final InventoryItem InventoryItem = new InventoryItem();

    public static Inventory open(Player p) {

        ItemStack Black = new Creator(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), "§7", null, 15, false).get();
        List<String> lore = Arrays.asList("", "§7查看制作月饼的原材料", "§7或查看月饼的种类", "", "§a点击打开");
        ItemStack Book = new Creator(XMaterial.BOOK.parseMaterial(), "§a物品图鉴", lore, 0, true).get();

        MYInventoryHolder holder = new MYInventoryHolder(p, 2);
        Inventory inv = Bukkit.createInventory(holder, InventoryType.CHEST, "§bMoonCake §7- §a主界面");

        for (int i = 0; i < 27; i++) {
            for (int s : slot) {
                if (i != s) {
                    inv.setItem(i, Black);
                }
                inv.setItem(s, Book);
                inv.setItem(InventorySlot.RECIPE_BUTTON, InventoryItem.TABLE);
            }
        }

        return inv;
    }
}
